package com.atguigu.adddemo1;

public class MainMethod {
    public static void main(String[] args) {
        Num num = new Num();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        num.add();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "aaa").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        num.sub();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "bbb").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        num.add();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "aaa1").start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100; i++) {
                    try {
                        num.sub();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }, "bbb1").start();
    }
}
